package com.hzit.consumer.controller;

import com.hzit.api.client.DeptClientService;
import com.hzit.api.entity.Dept;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/consumer")
public class ConsumerFeignController {

    @Autowired
    private DeptClientService deptClientService;

    @GetMapping("/list")
    public List<Dept> list() {
        List<Dept> list = deptClientService.list();
        return list;
    }

    @GetMapping("/get/{deptno}")
    public Dept get(@PathVariable("deptno") Integer deptno) {
        Dept dept = deptClientService.get(deptno);
        return dept;
    }

    @PostMapping("/add")
    public boolean add(@RequestBody Dept dept) {

        boolean add = deptClientService.add(dept);
        return add;
    }

}
